package com.fare.taluo.core.domain.crawl.statistics;

import java.util.List;

import javax.persistence.Column;

import com.dayatang.domain.Entity;
import com.dayatang.domain.InstanceFactory;
import com.dayatang.domain.QuerySettings;
import com.fare.taluo.core.domain.BaseEntity;
import com.fare.taluo.core.domain.crawl.TaskQueueLogEntityRepository;

@javax.persistence.Table(name="STATISTICS_TOTAL")
@javax.persistence.Entity
public class StatisticsTotalEntity extends BaseEntity<StatisticsTotalEntity> implements Entity{
	private static final long serialVersionUID = 7924245433935886065L;
	/*
		@javax.persistence.Table(name="CRAWL_TASK_QUEUE_LOG")
		@javax.persistence.Entity
public class TaskQueueLogEntity extends BaseEntity<TaskQueueLogEntity> implements Entity{

	private static final long serialVersionUID = 7924245433935886065L;
	@javax.persistence.Id
	@javax.persistence.Column(name="id", length=32)
	@javax.persistence.GeneratedValue(generator="system-uuid")
	@org.hibernate.annotations.GenericGenerator(name="system-uuid", strategy="uuid")
	private String id;
	*/
	@javax.persistence.Id
	@javax.persistence.Column(name="id", length=32)
	@javax.persistence.GeneratedValue(generator="system-uuid")
	@org.hibernate.annotations.GenericGenerator(name="system-uuid", strategy="uuid")
	private String id;
	@Column(name = "GRABCHANNEL")
	private String grabchannel;
	@Column(name = "GRABDATE")
	private String grabdate;
	@Column(name ="FROM_CITY")
	private String fromCity;
	@Column(name ="FROM_CITY_NAME")
	private String fromCityName;
	@Column(name ="TO_CITY")
	private String toCity;
	@Column(name ="TO_CITY_NAME")
	private String toCityName;
	@Column(name = "TOTAL")
	private Long total;
	@Column(name = "SUCCESS_NUM")
	private Long successNum;
	@Column(name = "FAIL_NUM")
	private Long failNum;
	@Column(name="ACTUAL_NUM")
	private Long actualNum;
	
	//各种失败原因的状态   -2表示      抓取失败
	//			   -3表示     解析失败  
	//			   -4表示    其他失败
	//             -10表示  未定义失败
	@Column(name="STATUS")
	private Long status;
	
	@Column(name="GRABCHANNEL_ID")
	private Long grabchannelID;
	
	@Column(name="SOURCE_DATA_SIZE")
	private Long sourceDataSize;
	
	@Column(name="byte_length")
	private Long allbyteLength;
	
	
	@Column(name="waiting")
	private Long waiting;
	
	@Column(name="starting")
	private long starting;

	@Column(name="min_time")
	private long minTime;
	
	@Column(name="max_time")
	private long maxTime;
	
	@Column(name="START_Time")
	private String startTime;
	
	
	public String getGrabchannel() {
		return grabchannel;
	}
	
	

	public String getId() {
		return id;
	}



	public void setId(String id) {
		this.id = id;
	}



	public void setGrabchannel(String grabchannel) {
		this.grabchannel = grabchannel;
	}



	public String getGrabdate() {
		return grabdate;
	}


	public void setGrabdate(String grabdate) {
		this.grabdate = grabdate;
	}

	

	public Long getStatus() {
		return status;
	}



	public void setStatus(Long status) {
		this.status = status;
	}

	

	public long getMinTime() {
		return minTime;
	}



	public void setMinTime(long minTime) {
		this.minTime = minTime;
	}



	public long getMaxTime() {
		return maxTime;
	}



	public void setMaxTime(long maxTime) {
		this.maxTime = maxTime;
	}



	public Long getSourceDataSize() {
		return sourceDataSize;
	}



	public void setSourceDataSize(Long sourceDataSize) {
		this.sourceDataSize = sourceDataSize;
	}



	public String getFromCity() {
		return fromCity;
	}



	public void setFromCity(String fromCity) {
		this.fromCity = fromCity;
	}



	public String getFromCityName() {
		return fromCityName;
	}



	public void setFromCityName(String fromCityName) {
		this.fromCityName = fromCityName;
	}



	public String getToCity() {
		return toCity;
	}



	public void setToCity(String toCity) {
		this.toCity = toCity;
	}



	public String getToCityName() {
		return toCityName;
	}



	public void setToCityName(String toCityName) {
		this.toCityName = toCityName;
	}



	public Long getTotal() {
		return total;
	}



	public void setTotal(Long total) {
		this.total = total;
	}



	public Long getSuccessNum() {
		return successNum;
	}



	public void setSuccessNum(Long successNum) {
		this.successNum = successNum;
	}



	public Long getFailNum() {
		return failNum;
	}



	public void setFailNum(Long failNum) {
		this.failNum = failNum;
	}



	public Long getActualNum() {
		return actualNum;
	}



	public void setActualNum(Long actualNum) {
		this.actualNum = actualNum;
	}


	public Long getGrabchannelID() {
		return grabchannelID;
	}



	public void setGrabchannelID(Long grabchannelID) {
		this.grabchannelID = grabchannelID;
	}



	public Long getAllbyteLength() {
		return allbyteLength;
	}



	public void setAllbyteLength(Long allbyteLength) {
		this.allbyteLength = allbyteLength;
	}



	public Long getWaiting() {
		return waiting;
	}



	public void setWaiting(Long waiting) {
		this.waiting = waiting;
	}



	public long getStarting() {
		return starting;
	}



	public void setStarting(long starting) {
		this.starting = starting;
	}



	
	public String getStartTime() {
		return startTime;
	}



	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}



	//	private static TaskQueueLogEntityRepository repository = InstanceFactory.getInstance(TaskQueueLogEntityRepository.class);
	private static TaskQueueLogEntityRepository getTaskQueueLogEntityRepository(){
		return InstanceFactory.getInstance(TaskQueueLogEntityRepository.class);
	}
	//引擎统计 total详细信息查询
			public List<StatisticsTotalEntity> getTotalRecordByDateAndChannel(String grabdate,String grabchannelID) throws Exception{
				return getTaskQueueLogEntityRepository().getTotalRecordByDateAndChannel(grabdate,grabchannelID);
			}
		
	
		
		public int getCountByDateAndChannel_2(String grabdate,String grabchannelID){
			return getTaskQueueLogEntityRepository().getCountByDateAndChannel_2(grabdate, grabchannelID);
		}



		@Override
		public boolean isNew() {
			return getId() == null ;
		}

		@Override
		public boolean existed() {
			if (isNew()) {
				return false;
			}
			return getRepository().exists(getClass(), getId());
		}

		@Override
		public boolean notExisted() {
			return ! existed();
		}
		
		@Override
		public boolean existed(String propertyName, Object propertyValue) {
			List<?> entities = getRepository().find(QuerySettings.create(getClass()).eq(propertyName, propertyValue)); 
			return !(entities.isEmpty());
		}
	
}


/*

@SuppressWarnings("serial")
@javax.persistence.Entity
@Table(name = "COAS.STATISTICS_TASK")
public class StatisticsTaskEntity extends BaseEntity<StatisticsTaskEntity> implements com.dayatang.domain.Entity{

	private static StatisticsTaskEntityRepository statisticsTaskEntityRepository = InstanceFactory.getInstance(StatisticsTaskEntityRepository.class);

	*//**
	 * @return查询所有
	 *//*
	public List<StatisticsTaskEntity> getStatisticsTaskEntity(){
		return statisticsTaskEntityRepository.getStatisticsTaskEntity();
	}
	*//**
	 * @return条件查询
	 *//*
	public List<StatisticsTaskEntity> getStatisticsTaskByCondition(String grabchannel,String beginTime,String endTime,String seachByType,String SymbolType,Long num){
		return statisticsTaskEntityRepository.getStatisticsTaskByCondition(grabchannel, beginTime, endTime, seachByType, SymbolType, num);
	}

}
*/

